package com.haoshuang.zhouzhoubang.ui.page.splash

import android.content.Context
import android.os.Bundle
import com.gyf.immersionbar.ktx.immersionBar
import com.haoshuang.zhouzhoubang.MyApp
import com.haoshuang.zhouzhoubang.R
import com.haoshuang.zhouzhoubang.databinding.ActivitySplashPageBinding
import com.haoshuang.zhouzhoubang.ui.page.account.login.LoginActivity
import com.haoshuang.zhouzhoubang.ui.page.main.MainActivity
import com.lnkj.jialubao.utils.AccountUtils
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.utils.CountDownWorker
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.toast
import com.mufeng.libs.utils.view.click


/**
 *
 */
class SplashPageActivity : BaseVMActivity<SplashPageViewModel, ActivitySplashPageBinding>() {

    companion object {
        fun launch(context: Context) {
            context.startPage<SplashPageActivity>()
        }
    }

    override fun initView(savedInstanceState: Bundle?) {

        if (AccountUtils.isAgreementDialog){
            MyApp.instance.initJpush()
        }

    }

    override fun initImmersionBar() {
        immersionBar {
            transparentStatusBar()
        }
    }

    override fun initData() {

        jumpMain()

    }

    private fun jumpMain() {
        CountDownWorker(this, total = 2) {
            if (AccountUtils.isLogin){
                startPage<MainActivity>()
            }else {
                startPage<LoginActivity>()
            }
            finish()
        }.start()
    }

    override fun startObserve() {

    }

}